<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE HTML>
<html>
<head>
<link href="${ctx}/static/h-ui/css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="${ctx}/static/h-ui.admin/css/H-ui.login.css" rel="stylesheet" type="text/css" />
<link href="${ctx}/static/h-ui.admin/css/style.css" rel="stylesheet" type="text/css" />
<link href="${ctx}/lib/Hui-iconfont/1.0.8/iconfont.css" rel="stylesheet" type="text/css" />
<title>云算盘</title>
</head>
<body>
<input type="hidden" id="TenantId" name="TenantId" value="" />
<div class="header"></div>
<div class="loginWraper">
  <div class="loginBox">
    <form class="form form-horizontal" action="post" id="loginForm">
      <div class="row cl">
        <label class="form-label col-xs-3"><i class="Hui-iconfont">&#xe60d;</i></label>
        <div class="formControls col-xs-8">
          <input name="username" id="username" value="admin" type="text" placeholder="账户" class="input-text size-L">
        </div>
      </div>
      <div class="row cl">
        <label class="form-label col-xs-3"><i class="Hui-iconfont">&#xe60e;</i></label>
        <div class="formControls col-xs-8">
          <input name="password" id="password" value="123456" type="password" placeholder="密码" class="input-text size-L">
        </div>
      </div>
      <div class="row cl">
        <div class="formControls col-xs-8 col-xs-offset-3">
          <input class="input-text size-L" type="text" placeholder="验证码" onblur="if(this.value==''){this.value='验证码:'}" onclick="if(this.value=='验证码:'){this.value='';}" name="code" id="code" value="" style="width:150px;">
          <img id="img" style="width: 111px; height: 40px;" src="${ctx}/login/getCode">
          <a onclick="reimg()">看不清，换一张</a> </div>
      </div>
      <div class="row cl">
        <div class="formControls col-xs-8 col-xs-offset-3">
          <label for="online">
            <input type="checkbox" name="online" id="online" value="">
           	 使我保持登录状态</label>
        </div>
      </div>
      <div class="row cl">
        <div class="formControls col-xs-8 col-xs-offset-3">
          <input name="" type="button" onclick="login();" class="btn btn-success radius size-L" value="&nbsp;登&nbsp;&nbsp;&nbsp;&nbsp;录&nbsp;" style="margin-right: 30px;">
          <input name="" type="reset" onclick="reset();" class="btn btn-default radius size-L" value="&nbsp;取&nbsp;&nbsp;&nbsp;&nbsp;消&nbsp;">
        </div>
      </div>
    </form>
  </div>
</div>
<div class="footer">潮合（海南）科技有限公司 Copyright：云算盘  v3.1</div>
<script type="text/javascript" src="${ctx}/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="${ctx}/static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript">
	$(function () {
		// 页面装载完成后,把焦点设置在账号输入处
		$("#username").focus();
		//在用户名处回车，密码获得焦点
		$("#username").keypress(function (e) {
			if (e.keyCode == 13) {
				$("#password").focus();
			}
		});
		//在密码文本框处回车，提交数据
		$("#password").keypress(function (e) {
			if (e.keyCode == 13) {
				login();
			}
		});
	});

	function login () {
		if ($("#username").val() == "") {
			alert('用户名不能为空！');
			return;
		}
		if ($("#password").val() == "") {
			alert('密码不能为空！');
			return;
		}
		if ($("#code").val() == "") {
			//alert('验证码不能为空！');
			//return;
		}
		// 序列化表单参数
		var serializedForm = $("#loginForm").serialize();
		$.post("${ctx}/login/login", serializedForm, function (result) {
			if ("succ" == result) {
				// 刷新列表页面
				window.location.replace("${ctx}/login/toztMain"); //如果发表成功则跳到列表界面
			} else {
				alert(result);
				$("#code").val("");
				reimg();
			}
		}, "json");
	}
	//重置
	function reset () {
		$("#username").val("");
		$("#password").val("");
		$("#code").val("");
	}
</script>

<script>
	function reimg () {
		var img = document.getElementById("img");
		img.src = "${ctx}/login/getCode?rnd=" + Math.random();
	}
</script>
</body>
</html>